package com.example.springboot.service.impl;

import com.example.springboot.mapper.StudentMapper;
import com.example.springboot.model.Student;
import com.example.springboot.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Student queryStudentById(Integer id) {

        return studentMapper.selectByPrimaryKey(id);

    }

    @Override
    @Transactional
    public int addStudent(Student student) {

       int count = studentMapper.insert(student);

        System.out.println("更新结果："+count);

        int a = 10/0;

        return count;
    }
}
